import common from '@/utils/network/common'

const path = {
  listPath: 'widget/listCustomWidgetByParentId',
  listPath2: 'widget/listCustomWidgetWithOutBtnByParentId',
  savePath: 'version/save',
  changeActivatedPath: 'version/changeActivated',
  deletePath: 'version/delete'
}

const service = {};

(function (service) {
  service.listCustomWidgetByParentId = (parentId) => {
    return common.get(path.listPath, { parentId: parentId })
  }
  service.listCustomWidgetWithOutBtnByParentId = (parentId) => {
    return common.get(path.listPath2, { parentId: parentId })
  }
  service.save = (data) => {
    return common.post(path.savePath, {}, data)
  }
  service.changeActivated = (id) => {
    return common.post(path.changeActivatedPath, { id }, null)
  }
  service.delete = (id) => {
    return common.post(path.deletePath, { id }, null)
  }
})(service)

export default service
